#include "TYSounder.h"

TYSounder* TYSounder::m_pInstance = NULL;
TYSounder::CFRelease TYSounder::Garbo;

TYSounder::TYSounder(void)
{
	m_bIsLoadBackground = false;
}


TYSounder::~TYSounder(void)
{
	CocosDenshion::SimpleAudioEngine::sharedEngine()->unloadEffect(s_sound_click2);
	SimpleAudioEngine::sharedEngine()->end();
}

bool TYSounder::init()
{
	SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic(s_background_menu_sound);

	SimpleAudioEngine::sharedEngine()->preloadEffect(s_sound_click2);

	return true;
}

void TYSounder::playBackground()
{
	if (!m_bIsLoadBackground)
	{
		CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic(s_background_menu_sound, true);
		m_bIsLoadBackground = true;
	}
	else
	{
		CocosDenshion::SimpleAudioEngine::sharedEngine()->rewindBackgroundMusic();
	}
	
}

void TYSounder::pauseBackground()
{
	CocosDenshion::SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}

void TYSounder::stopBackground()
{
	CocosDenshion::SimpleAudioEngine::sharedEngine()->stopBackgroundMusic();

	m_bIsLoadBackground = false;
}

void TYSounder::playClickSound()
{
	CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(s_sound_click2);
}
